using System.Threading.Tasks;
using RPG.Infrastructure.Core;

namespace RPG.Infrastructure.Events
{
    public interface IEventBus
    {
        Task PublishAsync<TEvent>(TEvent @event) where TEvent : DomainEvent;
        void Subscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : DomainEvent;
        void Unsubscribe<TEvent>(IEventHandler<TEvent> handler) where TEvent : DomainEvent;
    }

    public interface IEventHandler<in TEvent> where TEvent : DomainEvent
    {
        Task HandleAsync(TEvent @event);
    }
}
